package com.duolaibei.business.base;

import android.app.IntentService;
import android.content.Context;
import android.content.Intent;
import android.support.annotation.Nullable;

import com.baidu.mapapi.CoordType;
import com.baidu.mapapi.SDKInitializer;
import com.iflytek.cloud.SpeechUtility;
import com.uuzuche.lib_zxing.activity.ZXingLibrary;

/**
 * Created by xlm on 2017/10/26 0026
 */

public class DlbIntentService extends IntentService {
    /**
     * Creates an IntentService.  Invoked by your subclass's constructor.
     *
     * @param name Used to name the worker thread, important only for debugging.
     */
    private static final String TAG = "DlbIntentService";
    private static final String SERVICE_ACTON_NAME = "com.duolaibei.business.DlbInentService";

    /**
     * 开启初始化IntentService
     *
     * @param context
     */
    public static void startInitService(Context context) {
        Intent intent = new Intent();
        intent.setClass(context, DlbIntentService.class);
        intent.setAction(SERVICE_ACTON_NAME);
        context.startService(intent);
    }

    public DlbIntentService() {
        super(TAG);
    }

    @Override
    protected void onHandleIntent(@Nullable Intent intent) {
        if (intent != null) {
            if (SERVICE_ACTON_NAME.equals(intent.getAction())) {
                preformInit();
            }
        }
    }

    /**
     * 初始化操作
     */
    private void preformInit() {
        ZXingLibrary.initDisplayOpinion(this);//扫码
        //注意该方法要再setContentView方法之前实现
        SDKInitializer.initialize(this.getApplicationContext());//百度地图
        SDKInitializer.setCoordType(CoordType.BD09LL);
        //讯飞语音
        SpeechUtility.createUtility(this.getApplicationContext(), "appid=5b498987");
    }

}
